<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>js赋值运算符</title>
</head>
<body>
    <p>i=15,j=2</p>
    <p id="pid"></p>
    <button onclick="mysum()">结果</button>
    <hr>
    <p>i=15,j=2,m=i+=j</p>
    <p id="ppid"></p>
    <button onclick="mysum1()">结果</button>
    <hr>
    <p>i=15,j=2,m=i+j</p>
    <p id="pppid"></p>
    <button onclick="mysum2()">结果</button>
    <hr>
    <p>i=www.,j=jikexueyuan.com,m=i+j</p>
    <p id="ppppid"></p>
    <button onclick="mysum3()">结果</button>
    <hr>
    <p>i=2,j="5",m=i+j</p>
    <p id="pppppid"></p>
    <button onclick="mysum4()">结果</button>
    <script>
        function mysum() {
            var i=15;
            var j=2;
            var j=i;//js中是从右向左赋值，即把i的值赋值给j
            document.getElementById("pid").innerHTML=j;
        }
        function mysum1() {
            var i=15;
            var j=2;
            var m=i+=j;//i=i+j=17
            document.getElementById("ppid").innerHTML=m;
        }
        function mysum2() {
            var i="15";
            var j="2";
            var m=i+j //字符串运算符例1
            document.getElementById("pppid").innerHTML=m;
        }
        function mysum3() {
            var i="www.";
            var j="jikexueyuan.com";
            var m=i+j //字符串运算符例2
            document.getElementById("ppppid").innerHTML=m;
        }
        function mysum4() {
            var i=2;
            var j="5";
            var m=i+j //任何类型与字符串相加 都会被转换成字符串，结果是25
            document.getElementById("pppppid").innerHTML=m;
        }
    </script>
</body>
</html>